<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增设备型号')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-deviceModel-add">
			<div class="form-group">
				<label class="col-sm-3 control-label">型号：</label>
				<div class="col-sm-8">
					<input id="modelNumber" name="modelNumber" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label"><span style="color: red; ">*</span>类型：</label>
				<div class="col-sm-8">
					<input id="modelType" name="modelType" class="form-control" type="text" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">代号：</label>
				<div class="col-sm-8">
					<input id="modelCode" name="modelCode" class="form-control" type="text">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">设备类型：</label>
				<div class="col-sm-8">
					<div class="input-group" style="width: 100%">
						<select name="deviceType" class="form-control m-b" th:with="type=${@dict.getType('sys_device_type')}">
							<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
						</select>
					</div>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<input id="remark" name="remark" class="form-control" type="text">
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		// 去掉所有input的autocomplete, 显示指定的除外 
		$(function(){
			$('input:not([autocomplete]),textarea:not([autocomplete]),select:not([autocomplete])').attr('autocomplete', 'off');
		});
		var prefix = ctx + "system/deviceModel"
		$("#form-deviceModel-add").validate({
			rules:{
				modelCode:{
					remote: {
						url: prefix + "/checkModelCodeUnique",
						type: "post",
						dataType: "json",
						data: {
							name : function() {
								return $.common.trim($("#modelCode").val());
							}
						},
						dataFilter: function(data, type) {
							return $.validate.unique(data);
						}
					}
				},
			},
			messages: {
				"modelCode": {
					remote: "代号已经存在"
				},
			},
			focusCleanup: true
		});

		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/add", $('#form-deviceModel-add').serialize());
	        }
	    }
	</script>
</body>
</html>
